/*
 * @Descripttion:
 * @LastEditors: xzh
 * @LastEditTime: 2024-01-04 11:21:08
 */

import { object_Inf } from "@/utils/typings/index.type";
import Utils_MoldState from "../utils-moldState";
import { afterSaleStatisticEnum } from "../../index.type";
import Dile_APi from "@/api";

/*
 * @Descripttion:统计工具类
 * @LastEditors: xzh
 * @LastEditTime: 2023-10-15 23:08:29
 */
export default class Utils_Statistic extends Utils_MoldState {
  /**
   * @Author: xzh
   * @Descripttion: 统计数据映射
   * @Param:
   */
  static statisticMap: object_Inf = [
    {
      //t('page.dashboardManageArr.afterSaleDashboardArr.equipTotal')
      label: "page.dashboardManageArr.afterSaleDashboardArr.equipTotal",
      //t('page.dashboardManageArr.afterSaleDashboardArr.equipTotalContent')
      content:
        "page.dashboardManageArr.afterSaleDashboardArr.equipTotalContent",
      detailsLabel: "设备在线统计",
      value: afterSaleStatisticEnum.equipTotal,
      type: "equip",
      icon: "setting",
      color: "#F5BC50",
    },
    {
      //t('page.dashboardManageArr.afterSaleDashboardArr.equipRepair')
      label: "page.dashboardManageArr.afterSaleDashboardArr.equipRepair",
      //t('page.dashboardManageArr.afterSaleDashboardArr.equipRepairContent')
      content:
        "page.dashboardManageArr.afterSaleDashboardArr.equipRepairContent",
      detailsLabel: "设备类别维修情况",
      value: afterSaleStatisticEnum.equipRepair,
      type: "equip",
      icon: "repair",
      color: "#1bc3d3",
    },
    {
      //t('page.dashboardManageArr.afterSaleDashboardArr.equipUpkeep')
      label: "page.dashboardManageArr.afterSaleDashboardArr.equipUpkeep",
      //t('page.dashboardManageArr.afterSaleDashboardArr.equipUpkeepContent')
      content:
        "page.dashboardManageArr.afterSaleDashboardArr.equipUpkeepContent",
      detailsLabel: "设备类别保养情况",
      value: afterSaleStatisticEnum.equipUpkeep,
      type: "equip",
      icon: "upkeep",
      color: "#eb3d56",
    },
    {
      //t('page.dashboardManageArr.afterSaleDashboardArr.moldTotal')
      label: "page.dashboardManageArr.afterSaleDashboardArr.moldTotal",
      //t('page.dashboardManageArr.afterSaleDashboardArr.moldTotalContent')
      content: "page.dashboardManageArr.afterSaleDashboardArr.moldTotalContent",
      detailsLabel: "模具在线统计",
      value: afterSaleStatisticEnum.moldTotal,
      type: "mold",
      icon: "setting",
      color: "#F5BC50",
    },
    {
      //t('page.dashboardManageArr.afterSaleDashboardArr.moldRepair')
      label: "page.dashboardManageArr.afterSaleDashboardArr.moldRepair",
      //t('page.dashboardManageArr.afterSaleDashboardArr.moldRepairContent')
      content:
        "page.dashboardManageArr.afterSaleDashboardArr.moldRepairContent",
      detailsLabel: "模具类别维修情况",
      value: afterSaleStatisticEnum.moldRepair,
      type: "mold",
      icon: "repair",
      color: "#1bc3d3",
    },
    {
      //t('page.dashboardManageArr.afterSaleDashboardArr.moldUpkeep')
      label: "page.dashboardManageArr.afterSaleDashboardArr.moldUpkeep",
      //t('page.dashboardManageArr.afterSaleDashboardArr.moldUpkeepContent')
      content:
        "page.dashboardManageArr.afterSaleDashboardArr.moldUpkeepContent",
      detailsLabel: "模具类别保养情况",
      value: afterSaleStatisticEnum.moldUpkeep,
      type: "mold",
      icon: "setting",
      color: "#F5BC50",
    },
  ];
  /**
   * @Author: xzh
   * @Descripttion: 统计表格列映射
   * @Param:
   */
  static statisticTableColumnMap = {
    //设备总数
    [afterSaleStatisticEnum.equipTotal]: [
      [
        {
          field: "equipmentCode",
          //t('page.equipManageArr.equipArchivesArr.code')
          title: "page.equipManageArr.equipArchivesArr.code",
        },
        {
          field: "equipmentName",
          //t('page.equipManageArr.equipArchivesArr.name')
          title: "page.equipManageArr.equipArchivesArr.name",
        },
        {
          field: "equipmentType",
          //t('page.equipManageArr.equipType')
          title: "page.equipManageArr.equipType",
        },
        {
          field: "onTime",
          title: "开机时间",
        },
      ],
    ],
    //设备维修
    [afterSaleStatisticEnum.equipRepair]: [
      //设备维修列
      [
        {
          field: "equipmentCode",
          //t('page.equipManageArr.equipArchivesArr.code')
          title: "page.equipManageArr.equipArchivesArr.code",
        },
        {
          field: "equipmentName",
          //t('page.equipManageArr.equipArchivesArr.name')
          title: "page.equipManageArr.equipArchivesArr.name",
        },
        {
          field: "startDate",
          //t('page.equipRepairArr.repairRecordArr.startDate')
          title: "page.equipRepairArr.repairRecordArr.startDate",
          formatter: "formatDateTime",
        },
        {
          field: "endDate",
          //t('page.equipRepairArr.repairRecordArr.endDate')
          title: "page.equipRepairArr.repairRecordArr.endDate",
          formatter: "formatDateTime",
        },
        {
          field: "faultTypeName",
          //t('page.equipRepairArr.faultType')
          title: "page.equipRepairArr.faultType",
        },
        {
          field: "level",
          //t('page.equipRepairArr.repairRecordArr.repairLevel')
          title: "page.equipRepairArr.repairRecordArr.repairLevel",
        },
      ],
      //设备报警列
      [
        {
          field: "equipmentCode",
          //t('page.equipManageArr.equipArchivesArr.code')
          title: "page.equipManageArr.equipArchivesArr.code",
        },
        {
          field: "equipmentName",
          //t('page.equipManageArr.equipArchivesArr.name')
          title: "page.equipManageArr.equipArchivesArr.name",
        },
        {
          field: "alarmTime",
          //t('page.equipManageArr.equipTypeArr.alarmInfoArr.alarmTime')
          title: "page.equipManageArr.equipTypeArr.alarmInfoArr.alarmTime",
          formatter: "formatDateTime",
        },
        {
          field: "alarmContent",
          //t('page.equipManageArr.equipTypeArr.alarmInfoArr.alarmContent')
          title: "page.equipManageArr.equipTypeArr.alarmInfoArr.alarmContent",
        },
        {
          field: "position",
          //t('page.systemManageArr.position')
          title: "page.systemManageArr.position",
        },
        {
          field: "alarmLevel",
          //t('page.equipManageArr.equipTypeArr.alarmInfoArr.alarmLevel')
          title: "page.equipManageArr.equipTypeArr.alarmInfoArr.alarmLevel",
        },
      ],
    ],
    //设备保养
    [afterSaleStatisticEnum.equipUpkeep]: [
      //保养计划
      [
        {
          field: "equipmentCode",
          //t('page.equipManageArr.equipArchivesArr.code')
          title: "page.equipManageArr.equipArchivesArr.code",
        },
        {
          field: "equipmentName",
          //t('page.equipManageArr.equipArchivesArr.name')
          title: "page.equipManageArr.equipArchivesArr.name",
        },
        {
          field: "planCode",
          //t('page.equipUpkeepArr.upkeepPlanArr.code')
          title: "page.equipUpkeepArr.upkeepPlanArr.code",
        },
        {
          field: "planTypeName",
          //t('page.equipUpkeepArr.upkeepPlanArr.planType')
          title: "page.equipUpkeepArr.upkeepPlanArr.planType",
        },
        {
          field: "startDate",
          //t('page.equipUpkeepArr.upkeepPlanArr.startDate')
          title: "page.equipUpkeepArr.upkeepPlanArr.startDate",
          formatter: "formatDateTime",
        },
        {
          field: "endDate",
          //t('page.equipUpkeepArr.upkeepPlanArr.endDate')
          title: "page.equipUpkeepArr.upkeepPlanArr.endDate",
          formatter: "formatDateTime",
        },
      ],
      //保养记录
      [
        {
          field: "equipmentCode",
          //t('page.equipManageArr.equipArchivesArr.code')
          title: "page.equipManageArr.equipArchivesArr.code",
        },
        {
          field: "equipmentName",
          //t('page.equipManageArr.equipArchivesArr.name')
          title: "page.equipManageArr.equipArchivesArr.name",
        },
        {
          field: "planCode",
          //t('page.equipUpkeepArr.upkeepPlanArr.code')
          title: "page.equipUpkeepArr.upkeepPlanArr.code",
        },
        {
          field: "planTypeName",
          //t('page.equipUpkeepArr.upkeepPlanArr.planType')
          title: "page.equipUpkeepArr.upkeepPlanArr.planType",
        },
        {
          field: "startDate",
          //t('page.equipUpkeepArr.upkeepRecordArr.startDate')
          title: "page.equipUpkeepArr.upkeepRecordArr.startDate",
          formatter: "formatDateTime",
        },
        {
          field: "endDate",
          //t('page.equipUpkeepArr.upkeepRecordArr.endDate')
          title: "page.equipUpkeepArr.upkeepRecordArr.endDate",
          formatter: "formatDateTime",
        },
      ],
    ],
    //模具总数
    [afterSaleStatisticEnum.moldTotal]: [
      {
        field: "mouldCode",
        //t('page.moldManageArr.moldArchivesArr.code')
        title: "page.moldManageArr.moldArchivesArr.code",
      },
      {
        field: "mouldName",
        //t('page.moldManageArr.moldArchivesArr.name')
        title: "page.moldManageArr.moldArchivesArr.name",
      },
      {
        field: "type",
        //t('page.moldManageArr.moldType')
        title: "page.moldManageArr.moldType",
      },
      {
        field: "onTime",
        //t('page.moldManageArr.moldArchivesArr.onTime')
        title: "page.moldManageArr.moldArchivesArr.onTime",
      },
    ],
    //模具维修
    [afterSaleStatisticEnum.moldRepair]: [
      [
        {
          field: "mouldCode",
          //t('page.moldManageArr.moldArchivesArr.code')
          title: "page.moldManageArr.moldArchivesArr.code",
        },
        {
          field: "mouldName",
          //t('page.moldManageArr.moldArchivesArr.name')
          title: "page.moldManageArr.moldArchivesArr.name",
        },
        {
          field: "startDate",
          //t('page.moldRepairArr.moldFaultTypeArr.startDate')
          title: "page.moldRepairArr.moldFaultTypeArr.startDate",
        },
        {
          field: "endDate",
          //t('page.moldRepairArr.moldFaultTypeArr.endDate')
          title: "page.moldRepairArr.moldFaultTypeArr.endDate",
        },
        {
          field: "faultTypeName",
          //t('page.moldRepairArr.moldFaultType')
          title: "page.moldRepairArr.moldFaultType",
        },
        {
          field: "level",
          //t('page.equipRepairArr.repairRecordArr.repairLevel')
          title: "page.equipRepairArr.repairRecordArr.repairLevel",
        },
      ],
      [
        {
          field: "mouldCode",
          //t('page.moldManageArr.moldArchivesArr.code')
          title: "page.moldManageArr.moldArchivesArr.code",
        },
        {
          field: "mouldName",
          //t('page.moldManageArr.moldArchivesArr.name')
          title: "page.moldManageArr.moldArchivesArr.name",
        },
        {
          field: "reporRepairDate",
          //t('page.moldRepairArr.moldReportArr.reporRepairTime')
          title: "page.moldRepairArr.moldReportArr.reporRepairTime",
          formatter: "formatDateTime",
        },
        {
          field: "reporRepairInfo",
          //t('page.moldRepairArr.moldReportArr.reporRepairContent')
          title: "page.moldRepairArr.moldReportArr.reporRepairContent",
        },
        {
          field: "position",
          //t('page.systemManageArr.position')
          title: "page.systemManageArr.position",
        },
        {
          field: "reporRepairLevel",
          //t('page.moldRepairArr.moldReportArr.reporRepairLevel')
          title: "page.moldRepairArr.moldReportArr.reporRepairLevel",
        },
      ],
    ],
    //模具保养
    [afterSaleStatisticEnum.moldUpkeep]: [
      [
        {
          field: "mouldCode",
          //t('page.moldManageArr.moldArchivesArr.code')
          title: "page.moldManageArr.moldArchivesArr.code",
        },
        {
          field: "mouldName",
          //t('page.moldManageArr.moldArchivesArr.name')
          title: "page.moldManageArr.moldArchivesArr.name",
        },
        {
          field: "planCode",
          //t('page.equipUpkeepArr.upkeepPlanArr.code')
          title: "page.equipUpkeepArr.upkeepPlanArr.code",
        },
        {
          field: "planTypeName",
          //t('page.equipUpkeepArr.upkeepPlanArr.planType')
          title: "page.equipUpkeepArr.upkeepPlanArr.planType",
        },
        {
          field: "startDate",
          //t('page.equipUpkeepArr.upkeepPlanArr.startDate')
          title: "page.equipUpkeepArr.upkeepPlanArr.startDate",
          formatter: "formatDateTime",
        },
        {
          field: "endDate",
          //t('page.equipUpkeepArr.upkeepPlanArr.endDate')
          title: "page.equipUpkeepArr.upkeepPlanArr.endDate",
          formatter: "formatDateTime",
        },
      ],
      [
        {
          field: "mouldCode",
          //t('page.moldManageArr.moldArchivesArr.code')
          title: "page.moldManageArr.moldArchivesArr.code",
        },
        {
          field: "mouldName",
          //t('page.moldManageArr.moldArchivesArr.name')
          title: "page.moldManageArr.moldArchivesArr.name",
        },
        {
          field: "planCode",
          //t('page.equipUpkeepArr.upkeepPlanArr.code')
          title: "page.equipUpkeepArr.upkeepPlanArr.code",
        },
        {
          field: "planTypeName",
          //t('page.equipUpkeepArr.upkeepPlanArr.planType')
          title: "page.equipUpkeepArr.upkeepPlanArr.planType",
        },
        {
          field: "startDate",
          //t('page.equipUpkeepArr.upkeepRecordArr.startDate')
          title: "page.equipUpkeepArr.upkeepRecordArr.startDate",
          formatter: "formatDateTime",
        },
        {
          field: "endDate",
          //t('page.equipUpkeepArr.upkeepRecordArr.endDate')
          title: "page.equipUpkeepArr.upkeepRecordArr.endDate",
          formatter: "formatDateTime",
        },
      ],
    ],
  };

  /**
   * @Author: xzh
   * @Descripttion: 获取售服统计数据
   * @Param:
   * @param {string} statisticType
   */
  static getAfterSaleStatistics = async (statisticType: string) => {
    let dataMap: object_Inf = {};
    switch (statisticType) {
      case afterSaleStatisticEnum.equipTotal:
        //设备总数
        dataMap = await Dile_APi.getAfterSaleEquipTotalStatistics();
        Object.assign(dataMap, {
          dataArr: [dataMap.data],
          dataSuffix: [
            //t('page.dashboardManageArr.afterSaleDashboardArr.onlineState')
            `page.dashboardManageArr.afterSaleDashboardArr.onlineState`,
          ],
        });
        break;
      case afterSaleStatisticEnum.equipRepair:
        //设备维修
        dataMap = await Dile_APi.getAfterSaleEquipRepairStatistics();
        Object.assign(dataMap, {
          dataArr: [dataMap.repairData, dataMap.alarmData],
          dataSuffix: [
            //t('page.abnormalManageArr.repairInfo')
            `page.abnormalManageArr.repairInfo`,
            //t('page.abnormalManageArr.alarmInfo')
            `page.abnormalManageArr.alarmInfo`,
          ],
        });
        break;
      case afterSaleStatisticEnum.equipUpkeep:
        //设备保养
        dataMap = await Dile_APi.getAfterSaleEquipUpkeepStatistics();
        Object.assign(dataMap, {
          dataArr: [dataMap.planData, dataMap.recordData],
          dataSuffix: [
            //t('page.equipUpkeepArr.upkeepPlan')
            `page.equipUpkeepArr.upkeepPlan`,
            //t('page.equipUpkeepArr.upkeepRecord')
            `page.equipUpkeepArr.upkeepRecord`,
          ],
        });
        break;
      case afterSaleStatisticEnum.moldTotal:
        //模具总数
        dataMap = await Dile_APi.getAfterSaleMoldTotalStatistics();
        Object.assign(dataMap, {
          dataArr: [dataMap.data],
          dataSuffix: [
            //t('page.dashboardManageArr.afterSaleDashboardArr.onlineState')
            `page.dashboardManageArr.afterSaleDashboardArr.onlineState`,
          ],
        });
        break;
      case afterSaleStatisticEnum.moldRepair:
        //模具维修
        dataMap = await Dile_APi.getAfterSaleMoldRepairStatistics();
        Object.assign(dataMap, {
          dataArr: [dataMap.repairData, dataMap.reportRepairData],
          dataSuffix: [
            //t('page.abnormalManageArr.repairInfo')
            `page.abnormalManageArr.repairInfo`,
            //t('page.dashboardManageArr.afterSaleDashboardArr.reportRepairInfo')
            `page.dashboardManageArr.afterSaleDashboardArr.reportRepairInfo`,
          ],
        });
        break;
      case afterSaleStatisticEnum.moldUpkeep:
        //模具维修
        dataMap = await Dile_APi.getAfterSaleMoldUpkeepStatistics();
        Object.assign(dataMap, {
          dataArr: [dataMap.planData, dataMap.recordData],
          dataSuffix: [
            //t('page.equipUpkeepArr.upkeepPlan')
            `page.equipUpkeepArr.upkeepPlan`,
            //t('page.equipUpkeepArr.upkeepRecord')
            `page.equipUpkeepArr.upkeepRecord`,
          ],
        });
        break;
    }
    return dataMap;
  };
}
